#ifndef ALIANALYSISTASKESDMUONFILTERO_H
#define ALIANALYSISTASKESDMUONFILTERO_H
 
/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 * See cxx source for full Copyright notice                               */

/* $Id: AliAnalysisTaskESDMuonFilterO.h 47793 2011-02-25 08:45:55Z martinez $ */ 

//
// Add the muon tracks to the generic AOD track branch during the 
// filtering of the ESD. 
//
// Authors: R. Arnaldi 5/5/08 and L. Aphecetche January 2011

#ifndef ALIANALYSISTASKSE_H
#  include "AliAnalysisTaskSE.h"
#  include "AliESDtrack.h"
#  include "AliAODTrack.h"
#  include "AliAODPid.h"
#  include "AliAODMuonReplicator0.h"
//#include "AliAOD3LH.h"

#endif
#ifndef ALIANALYSISCUTS_H
#  include "AliAnalysisCuts.h"
#endif

class AliAnalysisFilter;
class AliESDtrack;
class AliPIDResponse;

class AliAnalysisTaskESDMuonFilterO : public AliAnalysisTaskSE
{
 public:
    AliAnalysisTaskESDMuonFilterO(Bool_t onlyMuon=kTRUE, Bool_t keepAllEvents=kTRUE, Int_t mcMode=0, Int_t nsigmaTrk1=3 ,Int_t nsigmaTrk2 = 3, Int_t partType1 = 2,Int_t partType2 = 7);
    AliAnalysisTaskESDMuonFilterO(const char* name, Bool_t onlyMuon=kTRUE, Bool_t keepAllEvents=kTRUE, Int_t mcMode=0, Int_t nsigmaTrk1=3 ,Int_t nsigmaTrk2 = 3, Int_t partType1 = 2,Int_t partType2 = 7);
    virtual ~AliAnalysisTaskESDMuonFilterO() {;}
    // Implementation of interface methods
    virtual void UserCreateOutputObjects();
    virtual void Init();
    virtual void LocalInit() {Init();}
    virtual void UserExec(Option_t *option);
    virtual void Terminate(Option_t *option);

    virtual void ConvertESDtoAOD();
    virtual void SetAODPID(AliESDtrack *esdtrack, AliAODTrack *aodtrack, AliAODPid *detpid);
    void SetDetectorRawSignals(AliAODPid *aodpid, AliESDtrack *track);

    Bool_t IsHighDeDxParticle(AliESDtrack * const track);
    Bool_t IsTrackAccepted(AliESDtrack * const track);

    // Setters
    virtual void SetTrackFilter(AliAnalysisFilter* trackF) {fTrackFilter = trackF;}
    void SetWriteMuonAOD(Bool_t enableMuonAOD){fEnableMuonAOD = enableMuonAOD;}
    void SetWriteDimuonAOD(Bool_t enableDimuonAOD){fEnableDimuonAOD = enableDimuonAOD;}

    void PrintTask(Option_t *option="", Int_t indent=0) const;
 

 private:
    AliAnalysisTaskESDMuonFilterO(const AliAnalysisTaskESDMuonFilterO&);
    AliAnalysisTaskESDMuonFilterO& operator=(const AliAnalysisTaskESDMuonFilterO&);
    void AddFilteredAOD(const char* aodfilename, const char* title);

    AliAnalysisFilter* fTrackFilter; //  Track Filter
    Bool_t fEnableMuonAOD; // flag for enabling Muon AOD production
    Bool_t fEnableDimuonAOD; // flag for enabling Dimuon AOD production
    Bool_t fOnlyMuon; // flag for disabling branches irrelevant for (most) muon analyses
    Bool_t fKeepAllEvents; // keep even events where there's no muons (to get e.g. unbiased vertex distribution)
    Int_t  fMCMode; // whether and how we're filtering MC data
    
    Int_t fnSigmaTrk1;
    Int_t fnSigmaTrk2;
    Int_t fpartType1;
    Int_t fpartType2;

    AliAODMuonReplicator0* murep;

    AliPIDResponse  *fPIDResponse;                  //! PID response object

  ClassDef(AliAnalysisTaskESDMuonFilterO, 5); // Analysis task for standard ESD filtering
};
 
class AliAnalysisNonMuonTrackCuts : public AliAnalysisCuts
{
public:
  AliAnalysisNonMuonTrackCuts();
  virtual ~AliAnalysisNonMuonTrackCuts() {}
  virtual Bool_t IsSelected(TObject* obj);
  virtual Bool_t IsSelected(TList*   /* list */ ) { return kTRUE; }

  ClassDef(AliAnalysisNonMuonTrackCuts,1); // Select muon spectrometer tracks
};

class AliAnalysisNonPrimaryVertices : public AliAnalysisCuts
{
public:
  AliAnalysisNonPrimaryVertices();
  virtual ~AliAnalysisNonPrimaryVertices() {}
  virtual Bool_t IsSelected(TObject* obj);
  virtual Bool_t IsSelected(TList*   /* list */ ) { return kTRUE; }
  
  ClassDef(AliAnalysisNonPrimaryVertices,1); // Select primary vertices
};

#endif
